package ReadCommit.connection;

import java.util.Random;

public interface ReadCommitSql {
    String initTableSql = "drop table if exists account; create table account(id int, balance float, transaction_id int);";
    String initDataSql = "insert into account(id, transaction_id, balance) values (0, 1, 0), (1, 2, 100);";
    String selectBalanceSql = "select balance from account where transaction_id in (1,2);";
    String selectBalanceSqlLeft = "select balance as ";
    String selectBalanceSqlRight = " from account where transaction_id in (1,2);";
    String selectSumBalanceSql = "select sum(balance) as a from account where transaction_id in (1,2)";
    String increaseAccountSql = "update account set balance=balance+1 where transaction_id=1;";
    String decreaseAccountSql = "update account set balance=balance-1 where transaction_id=2;";

    default String getRandomId() {
        long timeMills = System.currentTimeMillis() / 1000000;
        int random = new Random().nextInt(1000000);
        return String.valueOf(timeMills) + String.valueOf(random);
    }
}
